<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //  Math.max(...arr)  对数组取最大值
        // 1. Math.max()
        var arr = [1,2,10,5,4]
        console.log(Math.max(...arr));

        // 2.算法实现
        var maxNum = arr[0]
        for(var i=1;i<arr.length;i++){
            if(maxNum<arr[i]){
                maxNum = arr[i]
            }
        }
        console.log(maxNum);
    </script>
</body>
</html>